home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Calc / MicroCalc.jar / CalcCanvas.class (.txt) next >
Encoding:
Java Class File  |  2001-09-07  |  10.9 KB  |  692 lines

  1. import javax.microedition.lcdui.Alert;
  2. import javax.microedition.lcdui.AlertType;
  3. import javax.microedition.lcdui.Canvas;
  4. import javax.microedition.lcdui.Command;
  5. import javax.microedition.lcdui.CommandListener;
  6. import javax.microedition.lcdui.Displayable;
  7. import javax.microedition.lcdui.Font;
  8. import javax.microedition.lcdui.Graphics;
  9. import javax.microedition.lcdui.Image;
  10.  
  11. public class CalcCanvas extends Canvas implements CommandListener {
  12.    // $FF: renamed from: x int
  13.    private int field_0 = 40;
  14.    // $FF: renamed from: y int
  15.    private int field_1 = 0;
  16.    private int key = 0;
  17.    private int action = 0;
  18.    private int keyId = 0;
  19.    private int arrow = 0;
  20.    private int keyPress = 0;
  21.    Command aboutCommand = new Command(Resources.getText(4), 1, 1);
  22.    Command helpCommand = new Command(Resources.getText(3), 1, 1);
  23.    Command exitCommand = new Command(Resources.getText(5), 7, 1);
  24.    private Image[] keys = new Image[14];
  25.    private Image[] digits = new Image[13];
  26.    private Image[] frames = new Image[3];
  27.    private Image[] arrows = new Image[3];
  28.    private Image[] drg = new Image[3];
  29.    // $FF: renamed from: m javax.microedition.lcdui.Image[]
  30.    private Image[] field_2 = new Image[1];
  31.    private Calculator calc = new Calculator();
  32.    private int[] digPos = new int[16];
  33.    private Position[] keyPos = new Position[14];
  34.    private String[] func = new String[]{"=", "+", "-", "*", "/", "x^y", "x^2", "1/x", "sqrt", "ln", "log", "sin", "cos", "tan", "asin", "acos", "atan", "n!", "e", "pi", "MC", "MR", "MS", "M+", Resources.getText(8)};
  35.    private int funcIndex = 1;
  36.    MicroCalc midlet;
  37.    Intro parent;
  38.  
  39.    public CalcCanvas(MicroCalc var1, Intro var2) {
  40.       this.midlet = var1;
  41.       this.parent = var2;
  42.       this.frames[0] = this.getImage("img/numframe.png");
  43.       this.frames[1] = this.getImage("img/drg.png");
  44.       this.frames[2] = this.getImage("img/error.png");
  45.       this.keys[0] = this.getImage("img/zero.png");
  46.       this.keys[1] = this.getImage("img/one.png");
  47.       this.keys[2] = this.getImage("img/two.png");
  48.       this.keys[3] = this.getImage("img/three.png");
  49.       this.keys[4] = this.getImage("img/four.png");
  50.       this.keys[5] = this.getImage("img/five.png");
  51.       this.keys[6] = this.getImage("img/six.png");
  52.       this.keys[7] = this.getImage("img/seven.png");
  53.       this.keys[8] = this.getImage("img/eight.png");
  54.       this.keys[9] = this.getImage("img/nine.png");
  55.       this.keys[10] = this.getImage("img/decimal.png");
  56.       this.keys[11] = this.getImage("img/sign.png");
  57.       this.keys[12] = this.getImage("img/up.png");
  58.       this.keys[13] = this.getImage("img/down.png");
  59.       this.digits[0] = this.getImage("img/zero1.png");
  60.       this.digits[1] = this.getImage("img/one1.png");
  61.       this.digits[2] = this.getImage("img/two1.png");
  62.       this.digits[3] = this.getImage("img/three1.png");
  63.       this.digits[4] = this.getImage("img/four1.png");
  64.       this.digits[5] = this.getImage("img/five1.png");
  65.       this.digits[6] = this.getImage("img/six1.png");
  66.       this.digits[7] = this.getImage("img/seven1.png");
  67.       this.digits[8] = this.getImage("img/eight1.png");
  68.       this.digits[9] = this.getImage("img/nine1.png");
  69.       this.digits[10] = this.getImage("img/point.png");
  70.       this.digits[11] = this.getImage("img/minus.png");
  71.       this.digits[12] = this.getImage("img/nominus.png");
  72.       this.arrows[0] = this.getImage("img/select.png");
  73.       this.arrows[1] = this.getImage("img/uppress.png");
  74.       this.arrows[2] = this.getImage("img/downpress.png");
  75.       this.drg[0] = this.getImage("img/deg.png");
  76.       this.drg[1] = this.getImage("img/rad.png");
  77.       this.drg[2] = this.getImage("img/grad.png");
  78.       this.field_2[0] = this.getImage("img/m.png");
  79.       this.digPos[0] = 3;
  80.       this.digPos[1] = 13;
  81.       this.digPos[2] = 20;
  82.       this.digPos[3] = 23;
  83.       this.digPos[4] = 30;
  84.       this.digPos[5] = 33;
  85.       this.digPos[6] = 40;
  86.       this.digPos[7] = 43;
  87.       this.digPos[8] = 50;
  88.       this.digPos[9] = 53;
  89.       this.digPos[10] = 60;
  90.       this.digPos[11] = 63;
  91.       this.digPos[12] = 70;
  92.       this.digPos[13] = 73;
  93.       this.digPos[14] = 80;
  94.       this.digPos[15] = 83;
  95.       this.keyPos[0] = new Position(21, 57);
  96.       this.keyPos[1] = new Position(0, 21);
  97.       this.keyPos[2] = new Position(21, 21);
  98.       this.keyPos[3] = new Position(42, 21);
  99.       this.keyPos[4] = new Position(0, 33);
  100.       this.keyPos[5] = new Position(21, 33);
  101.       this.keyPos[6] = new Position(42, 33);
  102.       this.keyPos[7] = new Position(0, 45);
  103.       this.keyPos[8] = new Position(21, 45);
  104.       this.keyPos[9] = new Position(42, 45);
  105.       this.keyPos[10] = new Position(0, 57);
  106.       this.keyPos[11] = new Position(42, 57);
  107.       this.keyPos[12] = new Position(67, 14);
  108.       this.keyPos[13] = new Position(67, 57);
  109.       this.funcIndex = 1;
  110.       CalcManager.initCalc();
  111.       this.calc.initCalculator();
  112.       this.calc.drg = 0;
  113.       ((Displayable)this).addCommand(this.helpCommand);
  114.       ((Displayable)this).addCommand(this.aboutCommand);
  115.       ((Displayable)this).addCommand(this.exitCommand);
  116.       ((Displayable)this).setCommandListener(this);
  117.    }
  118.  
  119.    public void commandAction(Command var1, Displayable var2) {
  120.       if (var1 == this.exitCommand) {
  121.          this.midlet.destroyApp(false);
  122.       } else if (var1 == this.aboutCommand) {
  123.          Alert var3 = new Alert(Resources.getText(0), Resources.getText(1), (Image)null, (AlertType)null);
  124.          var3.setTimeout(-2);
  125.          this.midlet.display.setCurrent(var3, this);
  126.       } else if (var1 == this.helpCommand) {
  127.          Alert var4 = new Alert(Resources.getText(3), Resources.getText(2), (Image)null, (AlertType)null);
  128.          var4.setTimeout(-2);
  129.          this.midlet.display.setCurrent(var4, this);
  130.       }
  131.  
  132.    }
  133.  
  134.    public void delay(int var1) {
  135.       try {
  136.          Thread.sleep((long)var1);
  137.       } catch (Exception var3) {
  138.          ((Throwable)var3).printStackTrace();
  139.       }
  140.  
  141.    }
  142.  
  143.    private Image getImage(String var1) {
  144.       try {
  145.          return Image.createImage("/" + var1);
  146.       } catch (Exception var2) {
  147.          return null;
  148.       }
  149.    }
  150.  
  151.    protected void hideNotify() {
  152.    }
  153.  
  154.    public void keyPressed(int var1) {
  155.       try {
  156.          this.key = ((Canvas)this).getGameAction(var1);
  157.          if (this.key > 0) {
  158.             switch (this.key) {
  159.                case 1:
  160.                   this.action = 2;
  161.                   if (this.funcIndex == 0) {
  162.                      this.funcIndex = this.func.length - 1;
  163.                   } else {
  164.                      --this.funcIndex;
  165.                   }
  166.  
  167.                   this.keyId = 12;
  168.                   this.arrow = 0;
  169.                   ((Canvas)this).repaint();
  170.                   ((Canvas)this).serviceRepaints();
  171.                   this.delay(100);
  172.                   this.arrow = 1;
  173.                   ((Canvas)this).repaint();
  174.                   ((Canvas)this).serviceRepaints();
  175.                   break;
  176.                case 2:
  177.                   this.action = 1;
  178.                   this.keyId = 16;
  179.                   CalcManager.delLast();
  180.                   ((Canvas)this).repaint();
  181.                   ((Canvas)this).serviceRepaints();
  182.                case 3:
  183.                case 4:
  184.                case 7:
  185.                default:
  186.                   break;
  187.                case 5:
  188.                   this.action = 3;
  189.                   this.keyId = 14;
  190.                   if (this.calc.drg == 0) {
  191.                      this.calc.drg = 1;
  192.                   } else if (this.calc.drg == 1) {
  193.                      this.calc.drg = 2;
  194.                   } else if (this.calc.drg == 2) {
  195.                      this.calc.drg = 0;
  196.                   }
  197.  
  198.                   ((Canvas)this).repaint();
  199.                   ((Canvas)this).serviceRepaints();
  200.                   break;
  201.                case 6:
  202.                   this.action = 2;
  203.                   if (this.funcIndex == this.func.length - 1) {
  204.                      this.funcIndex = 0;
  205.                   } else {
  206.                      ++this.funcIndex;
  207.                   }
  208.  
  209.                   this.keyId = 13;
  210.                   this.arrow = 0;
  211.                   ((Canvas)this).repaint();
  212.                   ((Canvas)this).serviceRepaints();
  213.                   this.delay(100);
  214.                   this.arrow = 1;
  215.                   ((Canvas)this).repaint();
  216.                   ((Canvas)this).serviceRepaints();
  217.                   break;
  218.                case 8:
  219.                   this.action = 4;
  220.                   this.keyId = 15;
  221.                   ((Canvas)this).repaint();
  222.                   ((Canvas)this).serviceRepaints();
  223.                   if (this.funcIndex == 24) {
  224.                      CalcManager.clearCurrValue();
  225.                      this.calc.initCalculator();
  226.                      this.action = 1;
  227.                      ((Canvas)this).repaint();
  228.                      ((Canvas)this).serviceRepaints();
  229.                      CalcManager.isNewValue = true;
  230.                   } else if (this.funcIndex == 20) {
  231.                      CalcManager.memory = MathFP.toFP("0");
  232.                      this.action = 6;
  233.                      ((Canvas)this).repaint();
  234.                      ((Canvas)this).serviceRepaints();
  235.                   } else if (this.funcIndex == 22) {
  236.                      CalcManager.memory = CalcManager.getCurrValueL();
  237.                      this.action = 6;
  238.                      ((Canvas)this).repaint();
  239.                      ((Canvas)this).serviceRepaints();
  240.                   } else if (this.funcIndex == 23) {
  241.                      CalcManager.memory = MathFP.add(CalcManager.memory, CalcManager.getCurrValueL());
  242.                      this.action = 6;
  243.                      ((Canvas)this).repaint();
  244.                      ((Canvas)this).serviceRepaints();
  245.                   } else {
  246.                      this.calc.calculate(this.funcIndex);
  247.                      this.action = 1;
  248.                      ((Canvas)this).repaint();
  249.                      ((Canvas)this).serviceRepaints();
  250.                      CalcManager.isNewValue = false;
  251.                   }
  252.  
  253.                   this.delay(100);
  254.                   this.funcIndex = 1;
  255.                   this.action = 2;
  256.                   ((Canvas)this).repaint();
  257.                   ((Canvas)this).serviceRepaints();
  258.             }
  259.          }
  260.  
  261.          if (var1 > 0) {
  262.             switch (var1) {
  263.                case 35:
  264.                   CalcManager.isNewValue = true;
  265.                   this.action = 5;
  266.                   this.keyId = 11;
  267.                   this.keyPress = 0;
  268.                   CalcManager.negative ^= true;
  269.                   CalcManager.currValL = MathFP.mul(CalcManager.currValL, MathFP.toFP("-1"));
  270.                   ((Canvas)this).repaint();
  271.                   ((Canvas)this).serviceRepaints();
  272.                   this.delay(100);
  273.                   this.keyPress = 1;
  274.                   ((Canvas)this).repaint();
  275.                   ((Canvas)this).serviceRepaints();
  276.                case 36:
  277.                case 37:
  278.                case 38:
  279.                case 39:
  280.                case 40:
  281.                case 41:
  282.                case 43:
  283.                case 44:
  284.                case 45:
  285.                case 46:
  286.                case 47:
  287.                default:
  288.                   break;
  289.                case 42:
  290.                   CalcManager.isNewValue = true;
  291.                   this.action = 1;
  292.                   this.keyId = 10;
  293.                   this.keyPress = 0;
  294.                   ((Canvas)this).repaint();
  295.                   ((Canvas)this).serviceRepaints();
  296.                   this.delay(100);
  297.                   this.keyPress = 1;
  298.                   ((Canvas)this).repaint();
  299.                   ((Canvas)this).serviceRepaints();
  300.                   break;
  301.                case 48:
  302.                   CalcManager.isNewValue = true;
  303.                   this.action = 1;
  304.                   this.keyId = 0;
  305.                   this.keyPress = 0;
  306.                   ((Canvas)this).repaint();
  307.                   ((Canvas)this).serviceRepaints();
  308.                   this.delay(100);
  309.                   this.keyPress = 1;
  310.                   ((Canvas)this).repaint();
  311.                   ((Canvas)this).serviceRepaints();
  312.                   break;
  313.                case 49:
  314.                   CalcManager.isNewValue = true;
  315.                   this.action = 1;
  316.                   this.keyPress = 0;
  317.                   this.keyId = 1;
  318.                   ((Canvas)this).repaint();
  319.                   ((Canvas)this).serviceRepaints();
  320.                   this.delay(100);
  321.                   this.keyPress = 1;
  322.                   ((Canvas)this).repaint();
  323.                   ((Canvas)this).serviceRepaints();
  324.                   break;
  325.                case 50:
  326.                   CalcManager.isNewValue = true;
  327.                   this.action = 1;
  328.                   this.keyId = 2;
  329.                   this.keyPress = 0;
  330.                   ((Canvas)this).repaint();
  331.                   ((Canvas)this).serviceRepaints();
  332.                   this.delay(100);
  333.                   this.keyPress = 1;
  334.                   ((Canvas)this).repaint();
  335.                   ((Canvas)this).serviceRepaints();
  336.                   break;
  337.                case 51:
  338.                   CalcManager.isNewValue = true;
  339.                   this.action = 1;
  340.                   this.keyId = 3;
  341.                   this.keyPress = 0;
  342.                   ((Canvas)this).repaint();
  343.                   ((Canvas)this).serviceRepaints();
  344.                   this.delay(100);
  345.                   this.keyPress = 1;
  346.                   ((Canvas)this).repaint();
  347.                   ((Canvas)this).serviceRepaints();
  348.                   break;
  349.                case 52:
  350.                   CalcManager.isNewValue = true;
  351.                   this.action = 1;
  352.                   this.keyId = 4;
  353.                   this.keyPress = 0;
  354.                   ((Canvas)this).repaint();
  355.                   ((Canvas)this).serviceRepaints();
  356.                   this.delay(100);
  357.                   this.keyPress = 1;
  358.                   ((Canvas)this).repaint();
  359.                   ((Canvas)this).serviceRepaints();
  360.                   break;
  361.                case 53:
  362.                   CalcManager.isNewValue = true;
  363.                   this.action = 1;
  364.                   this.keyId = 5;
  365.                   this.keyPress = 0;
  366.                   ((Canvas)this).repaint();
  367.                   ((Canvas)this).serviceRepaints();
  368.                   this.delay(100);
  369.                   this.keyPress = 1;
  370.                   ((Canvas)this).repaint();
  371.                   ((Canvas)this).serviceRepaints();
  372.                   break;
  373.                case 54:
  374.                   CalcManager.isNewValue = true;
  375.                   this.action = 1;
  376.                   this.keyId = 6;
  377.                   this.keyPress = 0;
  378.                   ((Canvas)this).repaint();
  379.                   ((Canvas)this).serviceRepaints();
  380.                   this.delay(100);
  381.                   this.keyPress = 1;
  382.                   ((Canvas)this).repaint();
  383.                   ((Canvas)this).serviceRepaints();
  384.                   break;
  385.                case 55:
  386.                   CalcManager.isNewValue = true;
  387.                   this.action = 1;
  388.                   this.keyId = 7;
  389.                   this.keyPress = 0;
  390.                   ((Canvas)this).repaint();
  391.                   ((Canvas)this).serviceRepaints();
  392.                   this.delay(100);
  393.                   this.keyPress = 1;
  394.                   ((Canvas)this).repaint();
  395.                   ((Canvas)this).serviceRepaints();
  396.                   break;
  397.                case 56:
  398.                   CalcManager.isNewValue = true;
  399.                   this.action = 1;
  400.                   this.keyId = 8;
  401.                   this.keyPress = 0;
  402.                   ((Canvas)this).repaint();
  403.                   ((Canvas)this).serviceRepaints();
  404.                   this.delay(100);
  405.                   this.keyPress = 1;
  406.                   ((Canvas)this).repaint();
  407.                   ((Canvas)this).serviceRepaints();
  408.                   break;
  409.                case 57:
  410.                   CalcManager.isNewValue = true;
  411.                   this.action = 1;
  412.                   this.keyId = 9;
  413.                   this.keyPress = 0;
  414.                   ((Canvas)this).repaint();
  415.                   ((Canvas)this).serviceRepaints();
  416.                   this.delay(100);
  417.                   this.keyPress = 1;
  418.                   ((Canvas)this).repaint();
  419.                   ((Canvas)this).serviceRepaints();
  420.             }
  421.          }
  422.       } catch (Exception var2) {
  423.       }
  424.  
  425.    }
  426.  
  427.    public void keyRepeated(int var1) {
  428.       this.keyPressed(var1);
  429.    }
  430.  
  431.    public void paint(Graphics var1) {
  432.       try {
  433.          Font var2 = Font.getFont(32, 0, 0);
  434.          Font var3 = Font.getFont(32, 0, 8);
  435.          var1.setColor(0);
  436.          if (this.action == 0) {
  437.             var1.setColor(16777215);
  438.             var1.fillRect(0, 0, 101, 69);
  439.             var1.setColor(0);
  440.             var1.drawImage(this.frames[0], 0, 0, 20);
  441.             this.field_0 = this.digPos[0];
  442.             this.field_1 = 2;
  443.             if (CalcManager.negative && CalcManager.currValL == MathFP.toFP("0")) {
  444.                CalcManager.negative = false;
  445.             }
  446.  
  447.             if (CalcManager.negative) {
  448.                var1.drawImage(this.digits[11], this.field_0, this.field_1, 20);
  449.             } else {
  450.                var1.drawImage(this.digits[12], this.field_0, this.field_1, 20);
  451.             }
  452.  
  453.             CalcManager.parseCurrValue();
  454.             this.field_1 = 2;
  455.             int var5 = CalcManager.numbers.length;
  456.  
  457.             for(int var6 = 0; var6 < var5; ++var6) {
  458.                this.field_0 = this.digPos[var6];
  459.                if (CalcManager.numbers[var6] != -1) {
  460.                   var1.drawImage(this.digits[CalcManager.numbers[var6]], this.field_0, this.field_1, 20);
  461.                }
  462.             }
  463.  
  464.             var1.drawImage(this.frames[1], 0, 13, 20);
  465.             var1.setFont(var3);
  466.             var1.drawImage(this.drg[this.calc.drg], 2, 13, 20);
  467.             if (CalcManager.memory != MathFP.toFP("0")) {
  468.                var1.drawImage(this.field_2[0], 35, 13, 20);
  469.             }
  470.  
  471.             for(int var7 = 0; var7 <= 13; ++var7) {
  472.                this.field_0 = this.keyPos[var7].x;
  473.                this.field_1 = this.keyPos[var7].y;
  474.                var1.drawImage(this.keys[var7], this.field_0, this.field_1, 20);
  475.             }
  476.  
  477.             this.field_0 = 90;
  478.             this.field_1 = 38;
  479.             var1.drawImage(this.arrows[0], this.field_0, this.field_1, 20);
  480.             var1.setColor(16777215);
  481.             var1.fillRect(62, 25, 28, 32);
  482.             var1.setColor(0);
  483.             this.field_0 = 77;
  484.             this.field_1 = 23;
  485.             this.field_1 = 39 - var3.getBaselinePosition() / 2;
  486.             int var8 = this.field_1 - var3.getBaselinePosition() - 1;
  487.             int var9 = this.field_1 + var3.getBaselinePosition() + 1;
  488.             var1.setFont(var3);
  489.             String var4;
  490.             if (this.funcIndex == 0) {
  491.                var4 = this.func[this.func.length - 1];
  492.             } else {
  493.                var4 = this.func[this.funcIndex - 1];
  494.             }
  495.  
  496.             var1.drawString(var4, this.field_0 - var3.stringWidth(var4) / 2, var8, 20);
  497.             var4 = this.func[this.funcIndex];
  498.             var1.drawString(var4, this.field_0 - var3.stringWidth(var4) / 2, this.field_1, 20);
  499.             if (this.funcIndex == this.func.length - 1) {
  500.                var4 = this.func[0];
  501.             } else {
  502.                var4 = this.func[this.funcIndex + 1];
  503.             }
  504.  
  505.             var1.drawString(var4, this.field_0 - var3.stringWidth(var4) / 2, var9, 20);
  506.          }
  507.  
  508.          if (this.action == 1) {
  509.             if (CalcManager.error) {
  510.                var1.drawImage(this.frames[2], 0, 0, 20);
  511.                CalcManager.clearCurrValue();
  512.                CalcManager.initCalc();
  513.                this.calc.initCalculator();
  514.                CalcManager.error = false;
  515.             } else if (this.keyId != 16 && this.keyId != 15) {
  516.                if (this.keyPress == 0) {
  517.                   this.field_0 = this.keyPos[this.keyId].x + 1;
  518.                   this.field_1 = this.keyPos[this.keyId].y + 1;
  519.                   var1.drawRect(this.field_0, this.field_1, 16, 8);
  520.                   var1.drawImage(this.frames[0], 0, 0, 20);
  521.                   var1.drawImage(this.frames[1], 0, 13, 20);
  522.                   var1.setFont(var3);
  523.                   var1.drawImage(this.drg[this.calc.drg], 2, 13, 20);
  524.                   if (CalcManager.memory != MathFP.toFP("0")) {
  525.                      var1.drawImage(this.field_2[0], 35, 13, 20);
  526.                   }
  527.  
  528.                   this.field_0 = this.digPos[0];
  529.                   this.field_1 = 2;
  530.                   CalcManager.addCurrent(this.keyId);
  531.                   CalcManager.currValL = CalcManager.getCurrValueL();
  532.                   CalcManager.parseCurrValue();
  533.                   if (CalcManager.negative && CalcManager.currValL == MathFP.toFP("0")) {
  534.                      CalcManager.negative = false;
  535.                   }
  536.  
  537.                   if (CalcManager.negative) {
  538.                      var1.drawImage(this.digits[11], this.field_0, this.field_1, 20);
  539.                   } else {
  540.                      var1.drawImage(this.digits[12], this.field_0, this.field_1, 20);
  541.                   }
  542.  
  543.                   this.field_1 = 2;
  544.                   int var17 = CalcManager.numbers.length;
  545.  
  546.                   for(int var20 = 0; var20 < var17; ++var20) {
  547.                      this.field_0 = this.digPos[var20];
  548.                      if (CalcManager.numbers[var20] != -1) {
  549.                         var1.drawImage(this.digits[CalcManager.numbers[var20]], this.field_0, this.field_1, 20);
  550.                      }
  551.                   }
  552.                } else if (this.keyPress == 1) {
  553.                   this.field_0 = this.keyPos[this.keyId].x;
  554.                   this.field_1 = this.keyPos[this.keyId].y;
  555.                   var1.drawImage(this.keys[this.keyId], this.field_0, this.field_1, 20);
  556.                }
  557.             } else {
  558.                var1.drawImage(this.frames[0], 0, 0, 20);
  559.                var1.drawImage(this.frames[1], 0, 13, 20);
  560.                var1.setFont(var3);
  561.                var1.drawImage(this.drg[this.calc.drg], 2, 13, 20);
  562.                if (CalcManager.memory != MathFP.toFP("0")) {
  563.                   var1.drawImage(this.field_2[0], 35, 13, 20);
  564.                }
  565.  
  566.                this.field_0 = this.digPos[0];
  567.                this.field_1 = 2;
  568.                if (CalcManager.negative && CalcManager.currValL == MathFP.toFP("0")) {
  569.                   CalcManager.negative = false;
  570.                }
  571.  
  572.                if (CalcManager.negative) {
  573.                   var1.drawImage(this.digits[11], this.field_0, this.field_1, 20);
  574.                } else {
  575.                   var1.drawImage(this.digits[12], this.field_0, this.field_1, 20);
  576.                }
  577.  
  578.                CalcManager.parseCurrValue();
  579.                int var16 = CalcManager.numbers.length;
  580.  
  581.                for(int var19 = 0; var19 < var16; ++var19) {
  582.                   this.field_0 = this.digPos[var19];
  583.                   if (CalcManager.numbers[var19] != -1) {
  584.                      var1.drawImage(this.digits[CalcManager.numbers[var19]], this.field_0, this.field_1, 20);
  585.                   }
  586.                }
  587.             }
  588.          } else if (this.action == 2) {
  589.             var1.setColor(16777215);
  590.             var1.fillRect(62, 25, 28, 32);
  591.             var1.setColor(0);
  592.             this.field_0 = 77;
  593.             this.field_1 = 23;
  594.             var1.setFont(var3);
  595.             this.field_1 = 39 - var3.getBaselinePosition() / 2;
  596.             int var18 = this.field_1 - var3.getBaselinePosition() - 1;
  597.             int var21 = this.field_1 + var3.getBaselinePosition() + 1;
  598.             String var13;
  599.             if (this.funcIndex == 0) {
  600.                var13 = this.func[this.func.length - 1];
  601.             } else {
  602.                var13 = this.func[this.funcIndex - 1];
  603.             }
  604.  
  605.             var1.drawString(var13, this.field_0 - var3.stringWidth(var13) / 2, var18, 20);
  606.             var13 = this.func[this.funcIndex];
  607.             var1.drawString(var13, this.field_0 - var3.stringWidth(var13) / 2, this.field_1, 20);
  608.             if (this.funcIndex == this.func.length - 1) {
  609.                var13 = this.func[0];
  610.             } else {
  611.                var13 = this.func[this.funcIndex + 1];
  612.             }
  613.  
  614.             var1.drawString(var13, this.field_0 - var3.stringWidth(var13) / 2, var21, 20);
  615.             if (this.keyId == 12) {
  616.                this.field_0 = this.keyPos[this.keyId].x;
  617.                this.field_1 = this.keyPos[this.keyId].y;
  618.                if (this.arrow == 0) {
  619.                   var1.drawImage(this.arrows[1], this.field_0, this.field_1, 20);
  620.                }
  621.  
  622.                if (this.arrow == 1) {
  623.                   var1.drawImage(this.keys[12], this.field_0, this.field_1, 20);
  624.                }
  625.             } else if (this.keyId == 13) {
  626.                this.field_0 = this.keyPos[this.keyId].x;
  627.                this.field_1 = this.keyPos[this.keyId].y;
  628.                if (this.arrow == 0) {
  629.                   var1.drawImage(this.arrows[2], this.field_0, this.field_1, 20);
  630.                }
  631.  
  632.                if (this.arrow == 1) {
  633.                   var1.drawImage(this.keys[13], this.field_0, this.field_1, 20);
  634.                }
  635.             }
  636.          } else if (this.action == 3) {
  637.             this.field_0 = 0;
  638.             this.field_1 = 13;
  639.             var1.drawImage(this.frames[1], this.field_0, this.field_1, 20);
  640.             this.field_0 = 3;
  641.             this.field_1 = 12;
  642.             var1.setFont(var3);
  643.             var1.drawImage(this.drg[this.calc.drg], 2, 13, 20);
  644.             if (CalcManager.memory != MathFP.toFP("0")) {
  645.                var1.drawImage(this.field_2[0], 35, 13, 20);
  646.             }
  647.          } else if (this.action == 4) {
  648.             var1.drawRect(62, 39 - var3.getBaselinePosition() / 2, 27, var3.getBaselinePosition() + 1);
  649.          } else if (this.action == 5) {
  650.             if (this.keyPress == 0) {
  651.                this.field_0 = this.keyPos[this.keyId].x + 1;
  652.                this.field_1 = this.keyPos[this.keyId].y + 1;
  653.                var1.drawRect(this.field_0, this.field_1, 16, 8);
  654.                this.field_0 = this.digPos[0];
  655.                this.field_1 = 2;
  656.                if (CalcManager.negative && CalcManager.currValL == MathFP.toFP("0")) {
  657.                   CalcManager.negative = false;
  658.                }
  659.  
  660.                if (CalcManager.negative) {
  661.                   var1.drawImage(this.digits[11], this.field_0, this.field_1, 20);
  662.                } else {
  663.                   var1.drawImage(this.digits[12], this.field_0, this.field_1, 20);
  664.                }
  665.             } else if (this.keyPress == 1) {
  666.                this.field_0 = this.keyPos[this.keyId].x;
  667.                this.field_1 = this.keyPos[this.keyId].y;
  668.                var1.drawImage(this.keys[this.keyId], this.field_0, this.field_1, 20);
  669.             }
  670.          } else if (this.action == 6) {
  671.             var1.drawImage(this.frames[1], 0, 13, 20);
  672.             var1.drawImage(this.drg[this.calc.drg], 2, 13, 20);
  673.             if (CalcManager.memory != MathFP.toFP("0")) {
  674.                var1.drawImage(this.field_2[0], 35, 13, 20);
  675.             }
  676.          }
  677.       } catch (Exception var10) {
  678.          System.out.println("Error in Paint: " + ((Throwable)var10).getMessage());
  679.          var1.drawImage(this.frames[2], 0, 0, 20);
  680.          CalcManager.clearCurrValue();
  681.          CalcManager.initCalc();
  682.          this.calc.initCalculator();
  683.          CalcManager.error = false;
  684.       }
  685.  
  686.    }
  687.  
  688.    protected void showNotify() {
  689.       this.action = 0;
  690.    }
  691. }
  692.